Back to Blog

Adding Ssh Key

2019-02-06

Adding SSH Key

Generating SSH keys allows developers to interface with certain remote services without having to constantly type out login information. You're going to set up an SSH key for GitHub.

Without a key, you won’t be able to push your code to GitHub without entering a password each time; trust us, that would be as irritating as needing a key to open every door in your home.

  1. Sign up for an account on https://github.com.

  2. Open up Terminal.

  3. We need to set up SSH keys. First, let’s make sure you don’t already have a set of keys on your computer. Type this into your Terminal window (copying and pasting will not work)

ls -al ~/.ssh

If no keys pop up, move on to step 4.

If keys do pop up, check that none of them are listed under id_rsa, like in this image:

SSH Instructions 1

If you do find a key with a matching name, then you can either overwrite it by following steps 4 to 6, or you can use the same key in steps 10 and beyond. Be advised that you'll have to remember the password tied to your key if you decide not to overwrite it.

  1. Type in this command along with your email to generate your keys:

ssh-keygen -t rsa -b 4096 -C "YOURGITHUBEMAIL@PLACEHOLDER.NET"

  1. When asked to enter a file to save the key, just hit return.
  1. When you’re finished, your window should look like this:

SSH Instructions 2

  1. For the next step, we need to use a tool called an ssh agent. Let’s test whether that’s working on your machine. Run this command in Terminal:

SSH Instructions 3

  1. Now run this command:
  1. When prompted for a passphrase, enter the one associated with the key.
  1. We need to add the key to GitHub. Copy the key to your clipboard by entering this command:
  1. Go to https://github.com/settings/ssh. Click the “New SSH key button.”

SSH Instructions 4

  1. When the form pops up, enter a name for your computer in the Title input. In the Key input, paste the SSH key you copied in Step 10.

SSH Instructions 5

  1. Now we just need to add GitHub to your computer’s list of acceptable SSH hosts. Go back to your Terminal window. Type in this command: ssh -T git@github.com

SSH Instructions 6

  1. You may now need to change the git settings to use SSH instead of url as it usually is done.